package cn.jinjie.day05.test1;

import java.util.Objects;

public class Test05 {
    public static void main(String[] args) {
        Student s1 = new Student("zs", 20);
        Student s3 = new Student("zs", 20);
        System.out.println(s1==s3);
        System.out.println(s1.equals(s3));
        System.out.println(s1);
        System.out.println(Objects.toString(s1));
        s1 = null;
        String s2 = Objects.toString(s1);//可以拿到toString之后的字符串，如果要对返回值做处理的话，可以用。另外还可以对s1进行是否为空的判断
        // String s3 = s1.toString();//这个就不行，会报空指针异常
        System.out.println(Objects.nonNull(s1));//可以改成方法的引用

        String a1 = "lisi";
        String a2 = "lisi";
        // a2 = null;
        a1.equals(a2);
        System.out.println(a2.equals(a1));
        System.out.println(Objects.equals(a1, a2));


    }
}
